package cn.zftt.common.config;

import cn.zftt.quartz.dao.JobLogDao;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author zhangfeng
 */
@Configuration
public class JobConfig {

    @Bean
    public JobLogListener jobLogListener(Scheduler scheduler, JobLogDao jobLogDao) {
        JobLogListener jobListener = new JobLogListener();
        jobListener.setJobLogDao(jobLogDao);
        try {
            scheduler.getListenerManager().addJobListener(jobListener);
        } catch (SchedulerException e) {
            e.printStackTrace();
        }
        return jobListener;
    }

}
